<table width="100%" border="1">
  <tr>
  	<th scope="col">Index</th>
    <th scope="col">Address</th>
    <th scope="col">Port</th>
    <th scope="col">Location</th>
    <th scope="col">Current Players</th>
    <th scope="col">Max Players</th>
    <th scope="col">Type</th>
    <th scope="col">Optional</th>
    <th scope="col">Owner</th>
  </tr>
<?php
$host="127.0.0.1" ;
$port=5050;
$timeout=30;
$serverList = array();
$sk=fsockopen($host,$port,$errnum,$errstr,$timeout) ;
if (!is_resource($sk)) {
    exit("connection fail: ".$errnum." ".$errstr) ;
} else {
	//Get Number of Servers in List so we know how many lines to get.
    fputs($sk, "MasterServer->List->GetCount->Get") ;
    $serverCount = fgets ($sk, 1024);
	//Get Servers
	fputs($sk, "MasterServer->List->ReceiveAll->All");
	$pos = 0;
	$servers = "";
	while($pos <= $serverCount - 1)
	{
			$serverList[$pos] = fgets($sk, 1024);
			$pos += 1;
	}
}
fclose($sk) ;
foreach($serverList as $i => $value)
{
	list($addr, $port, $loca, $cplayer, $mplayer, $type, $optional, $owner) = split(':', $value);
	echo("<tr>\n");
	echo("<td scope='col'>" . $i . "</td>\n");
    echo("<td scope='col'>" . $addr . "</td>\n");
    echo("<td scope='col'>" . $port . "</td>\n");
    echo("<td scope='col'>" . $loca . "</td>\n");
    echo("<td scope='col'>" . $cplayer . "</td>\n");
    echo("<td scope='col'>". $mplayer . "</td>\n");
   	echo("<td scope='col'>" . $type . "</td>\n");
  	echo("<td scope='col'>" . $optional . "</td>\n");
    echo("<td scope='col'>" . $owner . "</td>\n");
  	echo("</tr>\n");
}
?>
</table>
